package cn.arnold.offer.shangtang;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double x = in.nextDouble();
        double y = in.nextDouble();
        int n = in.nextInt(); //行
        double[][] nums = new double[n][2];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 2; j++) {
                nums[i][j] = in.nextDouble();
            }
        }
        List<Double> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            double xd = x - nums[i][0];
            double yd = y - nums[i][1];
            double distance = Math.sqrt(xd * xd + yd * yd);
            list.add(distance);
        }
        Collections.sort(list);
        Double res = list.get(0);
        DecimalFormat decimalFormat = new DecimalFormat("#,##0.000");
        String format = decimalFormat.format(res);
        System.out.println(format);
    }
}
